﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using TeamReview.Services;

namespace TeamReview
{
    public class CreateWorkItemViewModel : IDataErrorInfo
    {
        private ObservableCollection<QueryBindingItem> _queryFromList = null;
        private ObservableCollection<QueryBindingItem> _linkToList = null;
        private ObservableCollection<string> _assignedTo = null;
        private CreateReviewRequestWIModel _selectedRecord = null;
        private event PropertyChangedEventHandler PropertyChanged;
        private ObservableCollection<string> _priorityAllowedValues = null;
        private  ObservableCollection<string> _codeItemType=null; 
            
        public CreateWorkItemViewModel()
        {
            _priorityAllowedValues = new ObservableCollection<string>();
            _priorityAllowedValues.Add("Recommendation");// this is hardcode values and will not change
            _priorityAllowedValues.Add("Low");// this is hardcode values and will not change
            _priorityAllowedValues.Add("Medium");// this is hardcode values and will not change
            _priorityAllowedValues.Add("High");// this is hardcode values and will not change
            _priorityAllowedValues.Add("Critical");// this is hardcode values and will not change
            _priorityAllowedValues.Add("None");// this is hardcode values and will not change

            _codeItemType.Add("Review Request");// this is hardcode values and will not change

            _queryFromList = new ObservableCollection<QueryBindingItem>();  
            _linkToList = new ObservableCollection<QueryBindingItem>();
            _assignedTo = new ObservableCollection<string>();
            _selectedRecord = new CreateReviewRequestWIModel();
            _priorityAllowedValues = new ObservableCollection<string>();
            //_queryFromList.Add(new QueryBindingItem() { Name = "Hemant" });
            //_linkToList.Add(new QueryBindingItem() { Name = "WorkItem" });
            //_assignedTo.Add("ABC");
            //_priorityAllowedValues.Add("High");
            LoadDefaultValues();
        }

        private void LoadDefaultValues()
        {
            // get the Queryies Data
 
            //QueryDefinition 
            QueryHierarchy h = null;
            
                
        }
        public CreateReviewRequestWIModel SelectedRecord
        {
            get
            {
                return _selectedRecord;
            }
            set
            {
                _selectedRecord = value;
                this.NotifyPropertyChanged("SelectedRecord");

            }
        }
        public ObservableCollection<QueryBindingItem> QueryFromList
        {
            get
            {
                return _queryFromList;
            }
            set
            {
                _queryFromList = value;
            }
        }
        public ObservableCollection<QueryBindingItem> LinkToList
        {
            get
            {
                return _linkToList;
            }
            set
            {
                _linkToList = value;
            }
        }
        public ObservableCollection<string> AssignedToList
        {
            get
            {
                return _assignedTo;
            }
            set
            {
                _assignedTo = value;
            }
        }
        private string Title
        {
            get
            {
                return _selectedRecord.Title;
            }
            set
            {
                _selectedRecord.Title = value;
            }
        }
        public ObservableCollection<string> PriorityAllowedValuesList
        {
            get
            {
                return _priorityAllowedValues;
            }
            set
            {
                _priorityAllowedValues = value;
            }
        }

         public ObservableCollection<string> CodeItemType
        {
            get
            {
                return _codeItemType;
            }
            set
            {
                _codeItemType = value;
            }
        }

 //       
        public string Error
        {
            get { return null; }
        }

        public string this[string columnName]
        {
            get
            {
                string sResult = string.Empty;
                return sResult;
            }
        }
        protected void NotifyPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
